package menuBranch;


import java.awt.image.BufferedImage;
import java.util.LinkedList;

// Project: 

/******************************************************************************
 * <p>
 * File: drawTiles.java
 * </p>
 * @author  Tadhg O'Sullivan, rogue
 * @author <a href="mailto:tadhg.osullivan@ucdconnect.ie">tadhg.osullivan@ucdconnect.ie</a>
 * @version 1.0, 2007
 * @created 20-Feb-07 6:45:59 PM
 * @revised 21-Feb-07
 * <p>
 * Description: assigns coordinates to each tileObject and places them accordingly 
 * into a 2D array, returns a 2D array
 * </p>
 *****************************************************************************/

public class drawTiles {
	
	protected cropTileset tiles;
	protected BufferedImage tile;
	protected LinkedList<tileObject> ll;
	protected tileObject to;
	
	public tileObject[][] drawMap(){
		ll = new LinkedList<tileObject>();
        // a string holding the int that defines which tileObject is which
		String mapCoords = "1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,3,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,4,5,6,7,6,6,6,6,6,7,7,6,6,6,6,6,6,7,7,6,3,6,8,8,8,9,10,10,10,10,10,10,10,10,10,10,10,9,8,8,11,5,6,6,6,7,7,6,6,6,6,6,6,7,7,6,6,7,6,6,3,7,8,8,8,11,3,3,3,3,3,3,3,3,3,3,3,5,8,8,11,5,6,6,8,8,8,8,8,8,8,8,8,8,8,8,8,6,6,6,3,7,8,8,8,11,3,3,3,3,3,12,3,3,3,3,3,5,8,8,11,5,7,6,8,8,8,8,7,8,8,8,8,8,8,7,8,6,7,6,3,6,8,8,8,11,3,3,3,3,3,3,3,3,3,3,3,5,8,8,11,5,6,6,8,8,8,8,8,8,8,7,8,8,8,8,8,6,7,6,3,6,8,8,8,11,3,3,3,3,3,3,3,3,3,3,3,5,8,8,11,5,6,6,8,7,8,8,8,8,8,8,8,7,8,8,8,6,6,6,3,7,8,8,8,11,3,3,3,3,3,3,3,3,3,3,3,5,8,8,11,5,6,6,8,8,8,8,8,8,8,8,8,8,8,8,8,6,7,6,3,7,8,8,8,11,3,3,3,3,3,3,3,3,3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,8,8,8,8,8,6,8,8,8,8,8,8,8,6,5,6,6,9,9,9,8,8,8,8,8,8,8,9,9,9,6,7,6,3,7,8,6,6,6,7,7,6,6,7,6,7,8,8,8,8,8,8,8,7,5,7,7,6,9,9,9,9,9,22,9,9,9,9,9,6,7,7,7,3,7,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,7,5,6,6,7,6,9,9,9,9,9,9,9,9,9,6,6,7,6,7,3,6,7,7,6,6,7,6,7,6,6,6,6,8,8,8,8,8,8,8,6,23,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,3,6,6,7,7,6,6,6,6,7,6,6,6,6,6,6,6,6,6,6,6";
		String[] coords = mapCoords.split(",");
		int parsed = 0;
		tiles = new cropTileset();
		ll = tiles.importTileset();
		
		tileObject tileArray[][] = new tileObject[25][40];
		int coordsCount = 0;
		int posY=0;
		int posX;
		// get tileObjects from a LinkList and assign them coordinates and store them into the array
		for(int i = 0; i < 200; i += 8){
			posX=0;
			for(int j = 0; j < 320; j += 8){
				parsed = Integer.parseInt(coords[coordsCount]);
				ll.get(parsed).setX(j);
				ll.get(parsed).setY(i);
				tileArray[posY][posX] = ll.get(parsed - 1);
				coordsCount++;
				posX++;
			}
			posY++;
		}
	return tileArray;
	}
}
